<%--
    Document   : main
    Created on : 29-set-2010, 14.03.55
    Author     : erola
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Checkout</title>
        <link rel="stylesheet" type="text/css" href="css/style.css"/>
        <base target="_self"/>
    </head>
    <body>
        <%@include file="WEB-INF/jspf/header.jspf"%>
        <!-- start page -->
        <div id="content">

            <c:choose>
                <c:when test="${!empty sessionScope.username}">
                    <div class="post" style="background: url(images/checkout.png) no-repeat top right">
                        <h2 class="title">Checkout</h2>
                        <div class="entry">
                            <c:if test="${requestScope.err != null}">
                                <div class="error">
                                    ${err}
                                </div>
                            </c:if>
                            <p>Acquisto di ${requestScope.prodotti.size()} prodotti.</p>
                            <table width="100%">
                                <tr>
                                    <th>Codice</th>
                                    <th>Nome</th>
                                    <th>Prezzo</th>
                                </tr>
                                <c:set var="row" value="${0}" />
                                <c:forEach var="item" items="${sessionScope.carrello.getProdotti()}">
                                    <c:choose>
                                        <c:when test="${row mod 2 == 0}">
                                            <tr id="even">
                                            </c:when>
                                            <c:otherwise>
                                            <tr id="odd">
                                            </c:otherwise>
                                        </c:choose>
                                        <c:set var="row" value="${row+1}" />
                                        <td>${item.codice}</td>
                                        <td>${item.nome}</td>
                                        <td>${item.prezzo}0 €</td>
                                    </tr>
                                </c:forEach>
                                <tr>
                                    <td colspan="3">&nbsp;</td>
                                </tr>
                                <tr>
                                    <th colspan="2">&nbsp;</th>
                                    <th>Spedizione con corriere</th>
                                </tr>
                                <tr id="even">
                                    <td colspan="2" style="background-color: white">&nbsp;</td>
                                    <td>${requestScope.indirizzi} &times; ${requestScope.spedizione}0 €</td>
                                </tr>
                                <tr>
                                    <td colspan="3">&nbsp;</td>
                                </tr>
                                <tr>
                                    <th colspan="2">&nbsp;</th>
                                    <th>Totale</th>
                                </tr>
                                <tr id="even">
                                    <td colspan="2" style="background-color: white">&nbsp;</td>
                                    <td>${requestScope.totale}0 €</td>
                                </tr>
                                <tr>
                                    <td colspan="3">&nbsp;</td>
                                </tr>
                                <tr>
                                    <th colspan="2" style="text-align: right">
                                        <form action="CheckoutHandler" method="post">
                                            <input type="hidden" name="action" value="conferma" />
                                            <input type="hidden" name="totale" value="${requestScope.totale}" />
                                            <input type="submit" value="conferma"/>
                                        </form>
                                    </th>
                                    <th>
                                        <form action="account.jsp" method="post">
                                            <input type="submit" value="annulla"/>
                                        </form>
                                    </th>
                                </tr>
                            </table>
                        </div>
                    </div>
                </c:when>

                <c:otherwise>
                    <div class="post">
                        <h2 class="title">Errore</h2>

                        <div class="entry">
                            <p>Non sei loggato!</p>

                        </div>

                    </div>
                </c:otherwise>
            </c:choose>
        </div>

        <%@include file="WEB-INF/jspf/nav.jspf"%>
        <!-- end page -->

        <%@include file="WEB-INF/jspf/footer.jspf"%>
    </body>
</html>